package cn.gson.springboot.model.pjos;

import javax.persistence.*;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.Collection;
import java.util.Objects;

@Entity
public class Offer {
    private int offerId2;//报价单id
    private String offerTitle;//报价主题
    private String offerNumber;//报价单号
    private BigDecimal productOffer;//产品报价
    private String profit;//预估毛利
    private String paymentInstructions;//支付说明
    private String transportInstructions;//运输说明
    private int offerStatus;//审批状态
    private String offerRemarks;//报价单备注
    private Timestamp offerTime;//报价单创建时间
    private Emp offerEmp;//报价人
    private Integer approvaler;//审批人
    private Collection<Contract> contractsByOfferId2;
    private Customer customerByCustomId;//客户
    private BusinessInfo businessInfoByBusinesId;
    private Collection<OfferContractinfo> offerContractinfosByOfferId2;
    private Collection<OfferDetails> offerDetailsByOfferId2;

    @ManyToOne
    @JoinColumn(name="emp_id",referencedColumnName = "employees_id")
    public Emp getOfferEmp() {
        return offerEmp;
    }

    public void setOfferEmp(Emp offerEmp) {
        this.offerEmp = offerEmp;
    }



    @Id
    @Column(name = "offer_id2")
    @GeneratedValue(strategy = GenerationType.IDENTITY,generator = "seq")
    public int getOfferId2() {
        return offerId2;
    }

    public void setOfferId2(int offerId2) {
        this.offerId2 = offerId2;
    }

    @Basic
    @Column(name = "offer_title")
    public String getOfferTitle() {
        return offerTitle;
    }

    public void setOfferTitle(String offerTitle) {
        this.offerTitle = offerTitle;
    }
    @Basic
    @Column(name = "transport_Instructions")
    public String getTransportInstructions() {
        return transportInstructions;
    }

    public void setTransportInstructions(String transportInstructions) {
        this.transportInstructions = transportInstructions;
    }
    @Basic
    @Column(name = "approvaler")
    public Integer getApprovaler() {
        return approvaler;
    }

    public void setApprovaler(Integer approvaler) {
        this.approvaler = approvaler;
    }

    @Basic
    @Column(name = "offer_number")
    public String getOfferNumber() {
        return offerNumber;
    }

    public void setOfferNumber(String offerNumber) {
        this.offerNumber = offerNumber;
    }

    @Basic
    @Column(name = "product_offer")
    public BigDecimal getProductOffer() {
        return productOffer;
    }

    public void setProductOffer(BigDecimal productOffer) {
        this.productOffer = productOffer;
    }

    @Basic
    @Column(name = "profit")
    public String getProfit() {
        return profit;
    }

    public void setProfit(String profit) {
        this.profit = profit;
    }

    @Basic
    @Column(name = "payment_Instructions")
    public String getPaymentInstructions() {
        return paymentInstructions;
    }

    public void setPaymentInstructions(String paymentInstructions) {
        this.paymentInstructions = paymentInstructions;
    }

    @Basic
    @Column(name = "offer_status")
    public int getOfferStatus() {
        return offerStatus;
    }

    public void setOfferStatus(int offerStatus) {
        this.offerStatus = offerStatus;
    }

    @Basic
    @Column(name = "offer_remarks")
    public String getOfferRemarks() {
        return offerRemarks;
    }

    public void setOfferRemarks(String offerRemarks) {
        this.offerRemarks = offerRemarks;
    }

    @Basic
    @Column(name = "offer_time")
    public Timestamp getOfferTime() {
        return offerTime;
    }

    public void setOfferTime(Timestamp offerTime) {
        this.offerTime = offerTime;
    }



    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Offer offer = (Offer) o;
        return offerId2 == offer.offerId2 &&
                Objects.equals(offerNumber, offer.offerNumber) &&
                Objects.equals(productOffer, offer.productOffer) &&
                Objects.equals(profit, offer.profit) &&
                Objects.equals(paymentInstructions, offer.paymentInstructions) &&
                Objects.equals(offerStatus, offer.offerStatus) &&
                Objects.equals(offerRemarks, offer.offerRemarks) &&
                Objects.equals(offerTime, offer.offerTime);
    }

    @Override
    public int hashCode() {
        return Objects.hash(offerId2, offerNumber, productOffer, profit, paymentInstructions, offerStatus, offerRemarks, offerTime);
    }

    @OneToMany(mappedBy = "offerByOfferId2")
    public Collection<Contract> getContractsByOfferId2() {
        return contractsByOfferId2;
    }

    public void setContractsByOfferId2(Collection<Contract> contractsByOfferId2) {
        this.contractsByOfferId2 = contractsByOfferId2;
    }

    @ManyToOne
    @JoinColumn(name = "custom_id", referencedColumnName = "custom_id")
    public Customer getCustomerByCustomId() {
        return customerByCustomId;
    }

    public void setCustomerByCustomId(Customer customerByCustomId) {
        this.customerByCustomId = customerByCustomId;
    }

    @ManyToOne
    @JoinColumn(name = "busines_id", referencedColumnName = "busines_id")
    public BusinessInfo getBusinessInfoByBusinesId() {
        return businessInfoByBusinesId;
    }

    public void setBusinessInfoByBusinesId(BusinessInfo businessInfoByBusinesId) {
        this.businessInfoByBusinesId = businessInfoByBusinesId;
    }

    @OneToMany(mappedBy = "offerByOfferId2")
    public Collection<OfferContractinfo> getOfferContractinfosByOfferId2() {
        return offerContractinfosByOfferId2;
    }

    public void setOfferContractinfosByOfferId2(Collection<OfferContractinfo> offerContractinfosByOfferId2) {
        this.offerContractinfosByOfferId2 = offerContractinfosByOfferId2;
    }

    @OneToMany(mappedBy = "offerByOfferId2")
    public Collection<OfferDetails> getOfferDetailsByOfferId2() {
        return offerDetailsByOfferId2;
    }

    public void setOfferDetailsByOfferId2(Collection<OfferDetails> offerDetailsByOfferId2) {
        this.offerDetailsByOfferId2 = offerDetailsByOfferId2;
    }

    /*@Override
    public String toString() {
        return "Offer{" +
                "offerId2=" + offerId2 +
                ", offerNumber='" + offerNumber + '\'' +
                ", productOffer=" + productOffer +
                ", profit='" + profit + '\'' +
                ", paymentInstructions='" + paymentInstructions + '\'' +
                ", offerStatus='" + offerStatus + '\'' +
                ", offerRemarks='" + offerRemarks + '\'' +
                ", offerTime=" + offerTime +
                ", offerEmp=" + offerEmp +
                ", contractsByOfferId2=" + contractsByOfferId2 +
                ", customerByCustomId=" + customerByCustomId +
                ", businessInfoByBusinesId=" + businessInfoByBusinesId +
                ", offerContractinfosByOfferId2=" + offerContractinfosByOfferId2 +
                ", offerDetailsByOfferId2=" + offerDetailsByOfferId2 +
                '}';
    }*/
}
